var e = require("../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../@babel/runtime/helpers/objectSpread2"),
  n = require("../../../@babel/runtime/helpers/slicedToArray"),
  r = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  o = require("../../../config/index"),
  i = require("../../../store/index"),
  a = require("../../../utils/helper/common/index"),
  c = require("../../../utils/index").helper.share;
Page({
  componentPage: ["onPageScroll"],
  useStore: function (e) {
    return {
      isShowFreeInviteDialog: e.global.isShowFreeInviteDialog
    }
  },
  data: {
    content: "",
    isSalesman: 0
  },
  onLoad: function (e) {
    e.invite_code && (0, i.dispatch)(i.actions.storageActions.setItem({
      key: "INVITECODE",
      value: e.invite_code
    })), this.getDetailInfo(e)
  },
  getDetailInfo: function (i) {
    var a = this;
    return r(e().mark((function r() {
      var c, u, s, d, l, m, h, f, p, g, x, v;
      return e().wrap((function (e) {
        switch (e.prev = e.next) {
          case 0:
            if (i.mode != o.typeMode.recruit) {
              e.next = 9;
              break
            }
            return e.next = 3, $.request["GET/business/recruit/worker/detail/" + i.uuid]({}, {
              "content-type": "application/json"
            });
          case 3:
            c = e.sent, u = n(c, 1), l = u[0], l.data.time = l.data.createTime,
              l.data.timestamp = Date.parse(l.data.time) / 1000,l.data.phoneNumber = l.data.phone, e.next = 15;
            break;
          case 9:
            return e.next = 11, $.request[i.mode == 1 ? "GET/business/seek/rent/detail/" + i.uuid : "GET/business/for/rent/detail/" + i.uuid](t(t({}, i), {}, {
              info: i.uuid,
              source: "XCX"
            }));
          case 11:
            s = e.sent, d = n(s, 1), l = d[0], l.data.time = l.data.createTime,
              l.data.timestamp = Date.parse(l.data.time) / 1000, l.data.images = l.data.coverImageUrlList, l.data.area = l.data.provinceText + l.data.cityText, l.data.class = [{
                name: l.data.modelName
              }], l.data.phoneNumber = l.data.phone, l.data.phone = l.data.phone.replace(l.data.phone.substring(3, 11), "********")
          case 15:
            if (20002 !== l.code) {
              e.next = 23;
              break
            }
            m = t(t({}, i.mode == o.typeMode.recruit ? l.data : l.data), i), m.mode = i.mode, m.class = [{
              name: i.mode == 5 ? m.driverTypeName : m.modelName
            }], m.area = m.provinceText + m.cityText, m.phone = m.phone.replace(m.phone.substring(3, 11), "********"), h = m.is_free, f = m.getPhone, p = m.status, g = m.mode, x = "联系老板", 2 == p ? x = o.tagStatusList[g][Number(p)] : (h || f) && (x = "免费拨打"), v = o.tabList.find((function (e) {
              return e.mode == g
            })).title, a.setData({
              content: t(t({}, m), {}, {
                callText: x,
                typeText: v
              })
            }), a.getUserInfo(), e.next = 24;
            break;
          case 23:
            $.jxAlert({
              mode: "error",
              hideClose: !0,
              content: l.msg || "网络异常，请稍后再试"
            }).then((function () {
              $.router.back()
            }));
          case 24:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  getUserInfo() {
    $.request['GET/auth/info']().then(res => {
      var code = res[0].code
      var data = res[0].data
      var that = this;
      if (code === 20002) {
        that.setData({
          isSalesman: data.isSalesman
        })
      }
    })
  },
  onCall: function () {
    var t = this;
    return r(e().mark((function n() {
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            t.getPhone((function (e) {
              (0, a.callPhone)(e)
            }));
          case 1:
          case "end":
            return e.stop()
        }
      }), n)
    })))()
  },
  getPhone: function (t) {
    var n = this;
    return r(e().mark((function r() {
      var o, i, c;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            o = n.data.content, i = o.uuid, c = o.mode, 2 !== o.status && (0, a.getPhone)({
              id: i,
              mode: c
            }).then((function (e) {
              if (200 === e.code) {
                var r = e.content;
                n.setData({
                  "content.getPhone": !0,
                  "content.callText": "免费拨打"
                }), t(r)
              }
            }));
          case 2:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  onComplaint: function () {
    var e = this,
      t = this.data.content,
      n = t.is_report,
      r = t.getPhone,
      o = t.is_author,
      i = t.uuid,
      a = t.mode,
      c = t.status;
    o ? $.jxAlert({
      content: "您不能举报自己发布的信息"
    }) : n ? $.jxAlert({
      content: "您已经举报过这条信息了"
    }) : 2 == c ? $.jxAlert({
      content: "不能举报已完成的信息"
    }) : r ? $.router.push("/subpackage/common/complaint/index", {
      info: i,
      mode: a
    }) : $.jxAlert({
      mode: "warn",
      confirmText: "查看电话",
      content: "您还没查看电话号码，查看电话号码之后才能投诉。"
    }).then((function () {
      e.getPhone((function () {
        var t = e.data.content,
          n = t.uuid,
          r = t.mode;
        $.router.push("/subpackage/common/complaint/index", {
          info: n,
          mode: r
        })
      }))
    }))
  },
  onCloseInvite: function () {
    (0, i.dispatch)(i.actions.globalActions.setState({
      isShowFreeInviteDialog: !1
    }))
  },
  onShareAppMessage: function () {
    var e = this.data.content,
      t = e.title,
      n = e.images,
      r = e.uuid,
      o = e.mode;
    return c.getShareInfo(4, {
      title: t,
      imageUrl: null == n ? void 0 : n[0],
      params: {
        uuid: r,
        mode: o
      }
    })
  }
});